﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;


namespace test
{
    class Logger
    {

        public static void JustLog(string msg, string filename)
        {
            TextWriter w = File.AppendText(filename);

            w.Write(msg);
            w.Flush();
            w.Close();

        }

        public static void Log(String logMessage, string filename)
        {
            TextWriter w= File.AppendText(filename);

            w.Write("\r\nLog Entry : ");
            w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
                DateTime.Now.ToLongDateString());
            w.WriteLine("  :");
            w.WriteLine("  :{0}", logMessage);
            w.WriteLine("-------------------------------");
            // Update the underlying file.
            w.Flush();

            w.Close();

        }

        public static string DumpLog(string filename)
        {
            StringBuilder content = new StringBuilder();
            StreamReader r = new StreamReader(filename);
            // While not at the end of the file, read and write lines.
            String line;
            while ((line = r.ReadLine()) != null)
            {
                content.AppendLine(line);
                Console.WriteLine(line);
            }
            r.Close();

            return content.ToString();
        }

    }
}
